// 导包
import instance from '@/utils/axios.js'

const getLists = (data) => {
  return instance({
    url: '/target/selectByAid',
    method: 'post',
    params: data
  })
}
export { getLists }

const regExpData = (data) => {
  data.forEach(function (item) {
    const imgReg = /<img.*?(?:>|\/>)/gi
    const srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i
    const str = item.contents
    const arr = str.match(imgReg)
    const srcArr = []
    for (let i = 0; i < arr.length; i++) {
      const src = arr[i].match(srcReg)
      if (arr[i].indexOf('2019082005040264008793') == -1) {
        srcArr.push(`http:${src[1]}`)
      }
    }
    item.imgs = srcArr
    const textRegex = /<\/?.+?\/?>/gm
    const subst = ''
    const textResult = str.replace(textRegex, subst)
    item.text = textResult
  })
  return data
}
export { regExpData }
